<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>书信系统 - 主页面</title>
    <link rel="stylesheet" href="styles.css">
    <style>
        /* 主页面特有样式 */
        .container {
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            padding: 20px;
            box-sizing: border-box;
        }
        .letter-box {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 12px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
            padding: 40px 30px;
            width: 100%;
            max-width: 400px;
            text-align: center;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
        }
        .letter-box:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
        }
        h1 {
            color: #333;
            font-size: 28px;
            margin-bottom: 15px;
            font-weight: 600;
        }
        p {
            color: #666;
            margin-bottom: 25px;
            font-size: 16px;
        }
        #passwordForm {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        #password {
            padding: 12px 15px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 16px;
            transition: border-color 0.3s ease;
        }
        #password:focus {
            outline: none;
            border-color: #4a6cf7;
            box-shadow: 0 0 0 2px rgba(74, 108, 247, 0.2);
        }
        button[type="submit"] {
            background: #4a6cf7;
            color: white;
            border: none;
            border-radius: 6px;
            padding: 12px;
            font-size: 16px;
            cursor: pointer;
            transition: background 0.3s ease;
        }
        button[type="submit"]:hover {
            background: #3a5bdb;
        }
        .links-container {
            margin-top: 20px;
            display: flex;
            justify-content: center;
            gap: 20px;
        }
        .link-item a {
            color: #4a6cf7;
            text-decoration: none;
            transition: color 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 5px;
        }
        .link-item a:hover {
            color: #3a5bdb;
            text-decoration: underline;
        }
        .footer {
            margin-top: 30px;
            color: #666;
            font-size: 14px;
        }
        @media (max-width: 480px) {
            .letter-box {
                padding: 30px 20px;
            }
            h1 {
                font-size: 24px;
            }
            .links-container {
                flex-direction: column;
                gap: 10px;
            }
        }
        /* 添加装饰元素 */
        .decoration {
            position: absolute;
            width: 150px;
            height: 150px;
            border-radius: 50%;
            background: rgba(74, 108, 247, 0.1);
            z-index: 0;
        }
        .decoration-1 {
            top: 10%;
            left: 10%;
        }
        .decoration-2 {
            bottom: 10%;
            right: 10%;
        }
        .decoration-3 {
            top: 60%;
            left: 20%;
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <!-- 装饰元素 -->
    <div class="decoration decoration-1"></div>
    <div class="decoration decoration-2"></div>
    <div class="decoration decoration-3"></div>

    <div class="container">
        <div class="letter-box">
            <h1>书信系统</h1>
            <p>输入密码查看您的专属书信内容</p>
            <form id="passwordForm">
                <input type="password" id="password" placeholder="请输入密码" required>
                <button type="submit">查看书信</button>
            </form>
            <div class="links-container">
                <div class="link-item"><a href="converter.html">密码转换工具</a></div>
                <div class="link-item"><a href="admin_login.php">后台登录</a></div>
            </div>
        </div>
        <div class="footer">
            <p id="footer-text">加载中...</p>
            <p id="icp-info"></p>
        </div>
    </div>

    <script src="scripts.js"></script>
    <script>
        // 首次运行检测
        document.addEventListener('DOMContentLoaded', function() {
            // 检查是否是首次运行
            fetch('check_first_run.php')
                .then(response => response.json())
                .then(data => {
                    if (data.first_run) {
                        // 首次运行，重定向到欢迎页面
                        window.location.href = 'welcome.php';
                    } else {
                        // 加载底部信息
                        loadFooterInfo();
                    }
                })
                .catch(error => {
                    console.error('检测首次运行失败:', error);
                    // 加载底部信息
                    loadFooterInfo();
                });
        });

        // 加载底部信息
        function loadFooterInfo() {
            fetch('get_footer_info.php')
                .then(response => response.json())
                .then(data => {
                    document.getElementById('footer-text').textContent = data.footer_text || '书信系统';
                    document.getElementById('icp-info').textContent = data.icp_info || '';
                })
                .catch(error => {
                    console.error('加载底部信息失败:', error);
                    document.getElementById('footer-text').textContent = '书信系统';
                });
        }
    </script>
</body>
</html>